package com.wenlin.myproduction.binder;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.bean.GuessNumberBean;
import com.wenlin.myproduction.util.UI;

import me.drakeet.multitype.ItemViewBinder;

/**
 * @author 文琳
 * @Email 377979485@qq.com
 * @desc
 * @time 2022-12-20 星期二 19:15
 */
public class GuessNumberBinder extends ItemViewBinder<GuessNumberBean, GuessNumberBinder.VH> {


    @NonNull
    @Override
    protected VH onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        return new VH(inflater.inflate(R.layout.item_guess_number, parent, false));
    }

    @Override
    protected void onBindViewHolder(@NonNull VH holder, @NonNull GuessNumberBean item) {
        UI.setText(holder.tvTimes, item.getTimes());
        UI.setText(holder.tvAnswer, item.getAnswer());
        UI.setText(holder.tvTips, item.getTotalCorrect() + "A" + item.getTotalHas() + "B");
    }

    static class VH extends RecyclerView.ViewHolder {
        TextView tvTimes, tvAnswer, tvTips;

        public VH(@NonNull View itemView) {
            super(itemView);
            tvTimes = itemView.findViewById(R.id.tv_times);
            tvAnswer = itemView.findViewById(R.id.tv_answer);
            tvTips = itemView.findViewById(R.id.tv_tips);
        }
    }
}
